package cn.micai.base.io;

import java.io.File;

/**
 * 描述：How to get size of file in java
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/6/7 9:37
 */
public class GetSizeOfFileMain {

    public static void main(String [] args) {
        // Read the file
        File file = new File("D://test.txt");
        double fileSizeBytes = file.length();
        System.out.println("Size of file in bytes: " + fileSizeBytes + " bytes");
        System.out.println("Size of file in KB: " + (double)fileSizeBytes/1024 + " KB");
        System.out.println("Size of file in MB: " + (double)fileSizeBytes/(1024*1024) + " MB");
    }
}
